In this part, 4 pointwise defected linen images are investigated. Due to their roundness, the orientation of the defect (theta) degree is insignificant. As a result of that, theta can be taken as both 0° and 90° and also the degrees between them. Hence, first two of the images will be investigated by taking the theta 0° and the rest two by taking the theta as 90° as a parameter of Gabor filter function.
library(jpeg)
library(wvtool)
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric3_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
test<-gabor.filter(img_grey,30,0,4,0,1,TRUE)
Since the pointwise property of the defect, the orientation angle doesn't effect the quality of the Gabor filter. Thus for this and the next example, the Gabor filter is applied to the image by using the parameters lamda=30, theta=0, bandwidth=4, phi=0 and asp=1. The results are displayed. The filtered image can be seen in the lower right side above. By the Gabor filter, the defect became more obvious and easier to detect.
str(test$filtered_img)
newimage<-test$filtered_img
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
for(j in 1:16){
m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
out_of_control[k]=i
k<-k+1
}
}
out_of_control
library(jpeg)
img_original3<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid3.jpg")
plot(1:512, type='n')
rasterImage(img_original3, 1, 1, 512, 512)
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric18_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
test<-gabor.filter(img_grey,30,0,4,0,1,TRUE)
str(test$filtered_img)
newimage<-test$filtered_img
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
for(j in 1:16){
m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
out_of_control[k]=i
k<-k+1
}
}
out_of_control
img_original18<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid18.jpg")
plot(1:512, type='n')
rasterImage(img_original18, 1, 1, 512, 512)
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric19_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
test<-gabor.filter(img_grey,30,90,4,0,1,TRUE)
Since the pointwise property of the defect, the orientation angle doesn't effect the quality of the Gabor filter. Thus for this and the next example, the Gabor filter is applied to the image by using the parameters lamda=30, theta=90, bandwidth=4, phi=0 and asp=1. The results are displayed. The filtered image can be seen in the lower right side above. By the Gabor filter, the defect became more obvious and easier to detect.
str(test$filtered_img)
newimage<-test$filtered_img
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
for(j in 1:16){
m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
out_of_control[k]=i
k<-k+1
}
}
out_of_control
img_original19<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid19.jpg")
plot(1:512, type='n')
rasterImage(img_original19, 1, 1, 512, 512)
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric20_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
test<-gabor.filter(img_grey,30,90,4,0,1,TRUE)
str(test$filtered_img)
newimage<-test$filtered_img
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
for(j in 1:16){
m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
}
}
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
out_of_control[k]=i
k<-k+1
}
}
out_of_control
img_original20<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid20.jpg")
plot(1:512, type='n')
rasterImage(img_original20, 1, 1, 512, 512)
In this project, we were given 20 different images of linen which are defective and these defects must be detected by using some techniques and approaches. We converted the images into greyscale and we used Gabor filtering to segment textures and extract defective parts. The images were seperated into 3 groups due to its linen defect orientations in order to use the Gabor filter efficiently. These groups are formed as horizontally, vertically and pointwise defected linen images. Then, we divided the filtered images into 256 patches each have certain window size of 32x32. Since the local structures are important in our case, we concluded that performing operations on patches and constructing charts on them is important.
Throughtout the project, we observed that a perfect defect detection is almost impossible as the quantity and type of patterned images for evaluation increase. In our approach, by grouping images into vertical,horizontal and pointwise, we tried to increase the number of correct detection. In this project we only used windows of sized 32x32 however by increasing or decreasing the window size we may detect more number of defects. Also, for some cases, the patches cover only half of the defect which causes the decrease in defect detection rate. In our project, we observed that situation in image 5, that is why we had only 2 out-of-control patches on that image which are not covering the main defect in the middle of the linen image.
In conclusion, we think that identification of defect orientation is an important element of image processing and better methods can be developed by using machine learning algorithms, which needs more samples. Also, true specification of Gabor filter parameters and patch window sizes is substantial to have significant defect detection process.